/********************************************************************
	Created:	2011/02/22    12:00 
	Filename: 	EventTest.cpp
	Author:		falconwang
*********************************************************************/
#include <iostream>
#include "Visual2d/inc/AnimSprite.h"

using namespace std;

class Test
{
public:

	Test(Vis::AnimSprite* sprite) : m_pSprite(sprite) {
		Vis::SpriteDesc desc;
		Vis::AnimDesc   anim;
		m_pSprite = new Vis::AnimSprite(desc, anim);
		m_pSprite->AddEventListener("Fuck", EL_WRAP(Test, Fuck));
		m_pSprite->AddEventListener("Shit", EL_WRAP(Test, Shit));
		m_pSprite->AddEventListener("Both", EL_WRAP(Test, Fuck));
		m_pSprite->AddEventListener("Both", EL_WRAP(Test, Shit));
	}

	~Test()
	{
		delete m_pSprite;
	}

	void	Fuck(ES::Event* evt) { cout<<"Fuck"<<endl;}
	void	Shit(ES::Event* evt) { cout<<"Shit"<<endl;}

	void	Run()
	{
		ES::Event evt("Fuck");
		m_pSprite->DispatchEvent(evt);

		ES::Event evt2("Shit");
		m_pSprite->DispatchEvent(evt2);

		ES::Event evt3("Both");
		m_pSprite->DispatchEvent(evt3);

		m_pSprite->RemoveEventListener("Both", EL_WRAP(Test, Shit));
		m_pSprite->DispatchEvent(evt3);
	}

private:

	Vis::AnimSprite*		m_pSprite;
};

#if 0
int main()
{
	Test* p = new Test;
	p->Run();

	delete p;

	int x;
	cin>>x;
}
#endif